﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Advertising.ascx.cs" Inherits="controls_admin_Advertising" %>
<!-- table -->
<script src="../resources/scripts/jquery-1.6.4.js" type="text/javascript"></script>
<script src="../resources/scripts/jquery.tablednd_0_5.js" type="text/javascript"></script>
<script type="text/javascript">
    var variable = "0";
    var index = "";
    var j = jQuery.noConflict();
    j(document).ready(function () {
        j('#table-3').tableDnD({
            onDrop: function (table, row) {
                variable = j.tableDnD.serialize();
            }
        });
        j("input.update").click(function () {
            if (variable == "0")
                return false;
            j.ajax({
                type: "POST",
                url: "/services/Admin.asmx/ADVOrder",
                data: "{'id':'" + variable + "','module':'"+ <%=ddlModule.SelectedValue %> +"'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                beforeSend: function () {
                    j("#<%=divMessage.ClientID %>").html("");
                },
                success: function (message) {
                    if (message.d == false) {
                        j("#<%=divMessage.ClientID %>").html("<div id='message-error' class='message message-error'><div class='image'><img src='../resources/images/icons/error.png' alt='Error' height='32' /></div><div class='text'><h6>Lỗi</h6><span>Chưa thực hiện được!</span></div><div class='dismiss'><a href='#message-error'></a></div></div>");
                    }
                    else {
                        j("#<%=divMessage.ClientID %>").html("<div id='message-success' class='message message-success'><div class='image'><img src='../resources/images/icons/success.png' alt='Success' height='32' /></div><div class='text'><h6>Thông Báo</h6><span>Cập nhật thành công !</span></div><div class='dismiss'><a href='#message-success'></a></div></div>");
                    }
                },
                error: function (errormessage) {
                    j("#<%=divMessage.ClientID %>").html("<div id='message-error' class='message message-error'><div class='image'><img src='../resources/images/icons/error.png' alt='Error' height='32' /></div><div class='text'><h6>Lỗi</h6><span>Chưa thực hiện được!</span></div><div class='dismiss'><a href='#message-error'></a></div></div>");
                }
            });
        });
    });
</script>
<div class="box">
    <!-- box / title -->
    <div class="title">
        <h5 runat="server" id="title">
            Danh sách quảng cáo
        </h5>
    </div>
    <div id="divMessage" runat="server">
    </div>
    <div class="first-action">
        <div class="button">
            <a href="default.aspx?control=advertisingadd">
                <input value="Thêm Mới" type="button" /></a>
            <input type="button" value="Cập nhật thứ tự" id="Button3" class="update" runat="server" />
        </div>
        <div class="select">
            <asp:DropDownList runat="server" ID="ddlModule" AutoPostBack="true" OnSelectedIndexChanged="ddlModule_SelectedIndexChanged">
            </asp:DropDownList>
        </div>
    </div>
    <!-- end box / title -->
    <div class="table">
        <table id="table-3">
            <thead>
                <tr>
                    <th class="stt">
                        STT
                    </th>
                    <th>
                        Ảnh - Flash
                    </th>
                    <th>
                        Tên quảng cáo
                    </th>
                    <th>
                        Link tới
                    </th>
                    <th>
                        Ngày đăng
                    </th>
                    <th>
                        Ngày hạn
                    </th>
                    <th>
                        Tình trạng
                    </th>
                    <th class="edit">
                        Sửa
                    </th>
                    <th class="selected last">
                        <input type="checkbox" class="checkall" />
                    </th>
                </tr>
            </thead>
            <tbody>
                <asp:Repeater ID="rptAds" runat="server">
                    <ItemTemplate>
                        <tr id='<%#Eval("PICTURE_ID")%>' style="cursor: move">
                            <td align="center">
                                <%#Container.ItemIndex + 1%>
                            </td>
                            <td align="center">
                                <%#GetAds(Eval("PICTURE_PATH").ToString())%>
                            </td>
                            <td align="center">
                                <%#Eval("PICTURE_NAME")%>
                            </td>
                            <td align="center">
                                <%#Eval("TARGET_LINK")%>
                            </td>
                            <td align="center">
                                <%#Eval("START_DATE","{0:dd/MM/yyyy}")%>
                            </td>
                            <td align="center">
                                <%#Eval("END_DATE", "{0:dd/MM/yyyy}")%>
                            </td>
                            <td align="center">
                                <%#Eval("STATE")%>
                            </td>
                            <td align="center">
                                <a href="default.aspx?control=advertisingedit&id=<%#Eval("PICTURE_ID").ToString() + "&keyword=" + Keyword %>"
                                    class="edit" title="Chỉnh sửa">&nbsp;&nbsp;&nbsp;</a>
                            </td>
                            <td align="center" class="last">
                                <input id="chkBox" type="checkbox" value='<%#Eval("PICTURE_ID")%>' class="item" runat="server" />
                            </td>
                        </tr>
                    </ItemTemplate>
                </asp:Repeater>
            </tbody>
        </table>
        <div class="action">
            <asp:DropDownList ID="ddlAction" runat="server" OnSelectedIndexChanged="ddlAction_SelectedIndexChanged"
                AutoPostBack="true" CssClass="selectwidth">
                <asp:ListItem Value="0" class="folder-open" Text="---Chọn hành động---"></asp:ListItem>
                <asp:ListItem Value="1" class="locked" Text="Di chuyển tới thùng rác"></asp:ListItem>
                <asp:ListItem Value="2" class="unlocked" Text="Xóa vĩnh viễn"></asp:ListItem>
            </asp:DropDownList>
            <div class="button">
                <a href="default.aspx?control=advertisingadd">
                    <input value="Thêm Mới" type="button" /></a>
                <input type="button" value="Cập nhật thứ tự" class="update" id="update" runat="server" />
            </div>
        </div>
    </div>
</div>
